package com.liziba.trend.service;

import cn.hutool.core.collection.CollUtil;
import com.liziba.trend.api.IndexData;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @program: trend
 * @description: 基金数据获取服务
 * @author: liziba
 * @date: 2021-02-03 11:07
 */
@Service
@CacheConfig(cacheNames = "index_data")
public class IndexDataService {

    /**
     * 缓存中获取指定基金代码的基金数据
     * @param code          基金代码
     * @return
     * @throws Exception
     */
    @Cacheable(key = "'indexData-code-' + #p0")
    public List<IndexData> get(String code) throws Exception {
        IndexData indexData = new IndexData("n/a", 0);
        return CollUtil.toList(indexData);
    }
}
